/* GUI CONVERTED from gpsiver.p (converter v1.75) Sun Aug 13 18:35:44 2000 */
/* gpsiver.p - PROCEDURE TO GET SECUITY SITES OF USER                     */
/*****************************************************************************/
/* This subroutine determines whether a particular user is allowed to        */
/* enter data for a given site, based on his assigned user groups            */
/* It looks up the si_mstr based on either the si_recid (if available) or    */
/* the site.  If the si_mstr is found and has security assigned, compares    */
/* to see if any of the user's groups is among the security groups           */
/* (si_canrun) for the site.  Returns a code of 1 for authorized, 0 for NOT  */
/* authorized.  The calling program is expected to display any messages      */
/* and/or take other action based on that return code.                       */
/*                                                                           */
/* Called by icedit1.i and icedit2.i transaction edit routines as well as a  */
/* number of maintenance routines which get user data entry by site.         */
/*****************************************************************************/
/* parameters used:                                                          */
/* output variable:        authorized_site_list    character return code     */
/*                                                                           */
/*****************************************************************************/

    {mfdeclre.i}    /* COMMON VARIABLES                  */
    {mf1.i }         /* ADDITIONAL COMMON VARIABLES, SUCH */
                                 /* AS GLOBAL_USER_GROUPS             */

    define output parameter authorized_site_list  as character init "".
    define variable authorized as integer init 1.
    define variable group_indx          as integer.

         /* CHECK SITE FOR USER GROUP AUTHORIZATION */
	FOR EACH si_mstr NO-LOCK:
		
        if si_canrun <> "" then do:
            authorized = 0.

            if can-do (si_canrun + ",!*",global_userid) then
               authorized_site_list = authorized_site_list + "," + si_site.

            if authorized = 0 then
               do group_indx = 1 to num-entries(global_user_groups)
               while authorized = 0:
                  if can-do (si_canrun + ",!*",
                  entry(group_indx, global_user_groups) ) then
                     authorized_site_list = authorized_site_list + "," + si_site.
               end.  /* DO WHILE */
        end.  /* (IF ...) */
		else 
            authorized_site_list = authorized_site_list + "," + si_site.
	END.
